twstock模組:
realtime.get( )取得特定股票的即時資訊。
列出合庫金(5880)的即時資料:
import twstock
stock5880 =twstock.realtime.get('5880')
print(stock5880)
列出目前5檔買進金額與數量:
import twstock
stock5880 =twstock.realtime.get('5880')
stock5880['realtime']['best_bid_price']
stock5880['realtime']['best_bid_volume']
print(stock5880)
列出目前5檔賣出金額與數量:
import twstock
stock5880 =twstock.realtime.get('5880')
stock5880['realtime']['best_bid_price']
stock5880['realtime']['best_bid_volume']
stock5880['realtime']['best_ask_price']
stock5880['realtime']['best_ask_volume']
print(stock5880)
參考書籍:
洪錦魁 -- Python網路爬蟲:大數據擷取、清洗、儲存與分析:王者歸來 2019
林俊瑋, 林修博 --- Python:網路爬蟲與資料分析入門實戰 2018